﻿using System;

namespace KuiHuaBaoDian.Services.Animation {

    /// <summary>
    /// 动画状态
    /// </summary>
    public struct AnimationState {

        /// <summary>
        /// 短名哈希值,一般由<see cref="UnityEngine.Animator.StringToHash(string)"/>生成
        /// </summary>
        public int NameHash;

        /// <summary>
        /// 层
        /// </summary>
        public int Layer;

        public override readonly bool Equals(object obj) {
            if (obj is AnimationState other) {
                return other.NameHash == NameHash && other.Layer == Layer;
            }
            return false;
        }

        public override readonly int GetHashCode() => HashCode.Combine(NameHash, Layer);

        public override readonly string ToString() => $"[{nameof(AnimationState)}({nameof(NameHash)}={NameHash},{nameof(Layer)}={Layer})]";

        public static bool operator ==(AnimationState left, AnimationState right) => left.Equals(right);

        public static bool operator !=(AnimationState left, AnimationState right) => !left.Equals(right);
    }
}
